/**
 * Collections UI State Store
 * 仅管理客户端 UI 状态，不存储任何服务端数据
 */
import { create } from 'zustand';

interface CollectionsUIState {
    /** 搜索关键词 */
    searchQuery: string;
    /** 拖拽预览状态 */
    isDragging: boolean;
    /** 保存集合的加载状态 */
    isSaving: boolean;

    /** 设置搜索关键词 */
    setSearchQuery: (query: string) => void;
    /** 设置拖拽状态 */
    setIsDragging: (isDragging: boolean) => void;
    /** 设置保存状态 */
    setIsSaving: (isSaving: boolean) => void;
    /** 重置所有 UI 状态 */
    resetUI: () => void;
}

const initialState = {
    searchQuery: '',
    isDragging: false,
    isSaving: false,
};

export const useCollectionsUIStore = create<CollectionsUIState>((set) => ({
    ...initialState,

    setSearchQuery: (query) => set({ searchQuery: query }),
    setIsDragging: (isDragging) => set({ isDragging }),
    setIsSaving: (isSaving) => set({ isSaving }),
    resetUI: () => set(initialState),
}));
